<?php
require_once 'XMLFile.php';
require_once 'Attribute.php';
require_once 'TreeNode.php';
require_once 'User.php';
require_once 'Permission.php';
require_once 'Application.php';

//$xml = new XML("fichier.xml");
//$xml->createFile();
//echo "file name is ".$xml->getfilename()."<br>";
//echo "file dir is ".$xml->getfiledir()."<br>";

//<users>
//	<user name="test" prenom = "test2">
//		<permissions>
//			<permission name ="read"></permission>
//			<permission name ="write"></permission>
//		</permession>
//	</user>
//</users>

// $attrName1 = new attribute("name", "read");
// $attrName2 = new attribute("name", "write");

// $nodePer1  = new treenode("permission",array($attrName1),null,"");
// $nodePer2  = new treenode("permission",array($attrName2),null,"");

// $nodePerm = new treenode("permissions",null, array($nodePer1,$nodePer2),"");

// $attrName3 = new attribute("name", "test");
// $attrName4 = new attribute("prenom", "test2");

// $nodeUser = new treenode("user",array($attrName3,$attrName4),array($nodePerm),"");

// $nodeUsers = new treenode("users",null, array($nodeUser),"");


// $element = new treenode("etape1", array(new attribute("name", "France"),new attribute("date", "12/12/2012")), null, "Premiere etatpe");

//$xml = new XML("file.xml");
//$xml->createfile();
//$xml->add_node($element,$xml->get_xml_file());
//$xml->showAll();


//$user = new User("aamd");
//$user->hasPermission("write","User.xml");

// $user = new User("idic");
// $user->setFirstName("ibrahim");
// $user->setLastName("Dicko");
// $permission1 = new Permission("User2.xml", "Lecture");
// $permission2 = new Permission("User2.xml", "Ecriture");
// $user->setPermissions(array($permission1,$permission2));

// $usernode = new treenode("user",array(new attribute("login", $user->getLogin()),new attribute("firstName", $user->getFirstName()),new attribute("lastName", $user->getLastName())),array(
// 						 new treenode("files",null, array(
// 						 			  new treenode("file",array(new attribute("name", "user.xml"),new attribute("path", "c:\user.xml")),
// 						 							array(new treenode("permissions", null, 
// 						 										array(new treenode("permission",array(new attribute("name", $permission1->getName())), null, null),
// 						 											  new treenode("permission",array(new attribute("name", $permission2->getName())), null, null)),
// 						 									 null)), 
// 						 			  		null)), 
// 						 		null)), 
// 			null);

// $xml->add_node($usernode, $xml->get_xml_file());

$user = new User("testaamd");
$user->setFirstName("ahmed2");
$user->setLastName("amdah2");
$user->setPassword("jmb");

$xml =  new XML("User.xml");
$xml->load_file();
//Application::create_new_user($user,$xml);
//Application::update_user("aamd", $user, $xml);
//Application::delete_user("aamd", $xml);
$per = new Permission("PPAScript22.xml","hhah");
Application::setPermission($per, "aamd", $xml);


